package com.zh.edu.info.manager.service;

import com.zh.edu.info.manager.dao.OtherStudentDao;
import com.zh.edu.info.manager.dao.StudentDao;
import com.zh.edu.info.manager.domain.Student;

public class StudentService {
    private OtherStudentDao studentDao = new OtherStudentDao();

    public void selectStudent(String id) {
        studentDao.selectStudent(id);
    }

    public boolean addStudent(Student student) {
        return studentDao.addStudent(student);
    }

    public boolean idFind(String id) {
        Student[] arr = studentDao.findAll();
        boolean flag = false;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] != null && arr[i].getId().equals(id)) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    public Student[] showStudent() {
        Student[] arr = studentDao.findAll();
        boolean flag = false;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] != null) {
                flag = true;
            }
        }
        if (flag) {
            return arr;
        }else {
            return null;
        }
    }

    public void setStudent(String id, Student student) {
        studentDao.setStudent(id, student);
    }
}
